package com.maycurobj.view;

import lombok.Getter;
import lombok.Setter;

/**
 * 费用类型的 枚举
 * OA系统后端推送物品领用时ID转换用
 * 默认无法转换的 都输出0206
 */
public enum FeiYongLXEnum {

    ONE("0", "0206"),
    TWO("1", "0708"),
    three("2", "0608"),
    four("3", "0908"),
    five("4", "1009"),
    six("5", "1109"),
    seven("6", "1808"),

    ;

    @Setter
    @Getter
    private String name;
    @Setter
    @Getter
    private String code;

    FeiYongLXEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    /**
     *  idToValue
     * @param s
     * @return
     */
    public static String idToValue(String s) {
        if (s == null) {
            return "0206";
        }
        for (FeiYongLXEnum biz : FeiYongLXEnum.values()) {
            if (biz.getName().equals(s)) {
                return biz.getCode();
            }
        }
        return "0206";
    }

    /**
     * value to id
     */
    public static String valueToId(String s) {
        if (s == null) {
            return "0";
        }
        for (FeiYongLXEnum biz : FeiYongLXEnum.values()) {
            if (biz.getName().equals(s)) {
                return biz.getCode();
            }
        }
        return null;
    }
}
